package com.example.workbench.controller;

import com.example.workbench.common.api.CommonResult;
import com.example.workbench.common.command.AddUserCommand;
import com.example.workbench.common.command.LoginUserCommand;
import com.example.workbench.common.vo.BaseResultVo;
import com.example.workbench.service.IDbUserService;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import java.io.IOException;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 
 * @since 2024-06-26
 */
@RestController
@RequestMapping("/user")
public class DbUserController {
    @Autowired
    private IDbUserService userService;
    @PostMapping("/register")
    public CommonResult register(@RequestBody AddUserCommand command) throws Exception {
        return userService.register(command);
    }

    @PostMapping("/doLogin")
    public CommonResult doLogin(@RequestBody LoginUserCommand command) throws Exception {
        return userService.doLogin(command);
    }

    @GetMapping("getCode")
    public CommonResult getCode() throws IOException {
        return userService.getCode();
    }
}
